package com.codingfuture.glaciercommon.advice;

import com.codingfuture.glaciercommon.util.Result;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author :zxw
 * @date 2025-03-31 18:00
 * @description:
 */
@ControllerAdvice
public class ExceptionControllerAdvice {
    @ExceptionHandler(NullPointerException.class)
    @ResponseBody
     public Result<Void> nullPointerException(){
         System.out.println("nullPointerException");
         return Result.success("空指针异常");
     }

    @ExceptionHandler(InstantiationException.class)
    @ResponseBody
    public Result<Void> instantiationException(){
        System.out.println("instantiationException");
        return Result.success("数组下标越界");
    }
    @ExceptionHandler(BindException.class)
    @ResponseBody
    public Result<Void> reqPageParamExciption(){
        System.out.println("reqPageParamExciption");
        return Result.success("分页请求参数异常");
    }
}
